<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //
        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapWebRoutes();
        $this->mapAdminRoutes();
        $this->mapWebApiRoutes();
        $this->mapServiceRoutes();
        $this->mapWxRoutes();

        //$this->mapApiRoutes();
        //$this->mapApiV1Routes();
        $this->mapApiV2Routes();
        $this->mapApiV3Routes();
        $this->mapApiV4Routes();
        $this->mapApiV5Routes();
        $this->mapApiV6Routes();
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/web.php');
        });
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => 'api',
        ], function ($router) {
            require base_path('routes/api.php');
        });
    }


    /**
     * 版本1 API接口
     * */
    protected function mapApiV1Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v1.php');
        });
    }


    /**
     * 版本2API接口
     * */
    protected function mapApiV2Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v2.php');
        });
    }

    /**
     * 版本3 API接口
     * */
    protected function mapApiV3Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v3.php');
        });
    }

  /**
   * 版本4 API接口
   * */
    protected function mapApiV4Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v4.php');
        });
    }


    /**
     * 版本4 API接口
     * */
    protected function mapApiV5Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v5.php');
        });
    }

    /**
     * 版本4 API接口
     * */
    protected function mapApiV6Routes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/api-v6.php');
        });
    }

    /**
     * web api
     * */
    protected function mapWebApiRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => ''
        ], function ($router) {
            require base_path('routes/web-api.php');
        });
    }


    /**
     * 后台路由
     * */
    protected function mapAdminRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/web-admin.php');
        });
    }

    /**
     * 微信分享处理路由
     */
    protected function mapWxRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => '',
        ], function ($router) {
            require base_path('routes/web-wx.php');
        });
    }


    /**
     * 公共服务
     * */
    protected function mapServiceRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => ''
        ], function ($router) {
            require base_path('routes/service.php');
        });
    }



}

